package com.tang.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author tang jun liang
 * @Date 2023-05-25 09:31:35
 */
@Getter
public enum ApproveStatus {
    /**
     * 审批工作流的状态
     */
    FORM_STATE_DRAFT(10001, "待提交"),

    FORM_STATE_APPROVING(10002, "审批中"),

    FORM_STATE_ACCESS(10003, "已审批"),

    FORM_STATE_REJECTED(10004, "驳回"),

    FORM_STATE_CANCELING(10005, "作废中"),

    FORM_STATE_CANCELED(10006, "已作废"),

    FORM_STATE_PAID(10007, "已付款"),

    FORM_STATE_ACCEPT(10008, "已收款"),

    FORM_STATE_WRITE_OFF(10009, "已核销"),

    UNDER_REVIEW(10010, "反审核中"),

    FORM_STATE_VOUCHER_CREATED(10099, "已生成凭证"),

    UNKNOWN(0, "未知")
    ;


    @JsonValue
    @EnumValue
    private final Integer value;

    private final String desc;

    ApproveStatus(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }


    @JsonCreator
    public static ApproveStatus create(Integer value){
        for (ApproveStatus item: values()){
            if (item.getValue().equals(value)){
                return item;
            }
        }
        return UNKNOWN;
    }

}
